public class Prime {
    public static void main(String[] args) {
        int count = 0; // 用于计数每行打印的素数个数
        for (int number = 2; number <= 20000; number++) {
            if (isPrime(number)) {
                System.out.print(number + " ");
                count++;
                if (count % 5 == 0) { // 每行打印5个素数
                    System.out.println();
                }
            }
        }
    }
    // 判断是否为素数的函数
    public static boolean isPrime(int number) {
        if (number <= 1) {
            return false;
        }
        for (int i = 2; i * i <= number; i++) { // 只需检查到sqrt(number)
            if (number % i == 0) {
                return false;
            }
        }
        return true;
    }
}
